package com.superb.system.api.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import io.swagger.v3.oas.annotations.media.Schema;
import io.swagger.v3.oas.annotations.tags.Tag;
import com.baomidou.mybatisplus.annotation.TableName;
import com.superb.common.database.entity.BaseEntity;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.NotNull;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.List;

/**
 * 部门机构
 * @Author: ajie
 * @CreateTime: 2024-6-14
 */
@Data
@Tag(name = "部门机构")
@TableName("system_organization")
@EqualsAndHashCode(callSuper=false)
public class Organization extends BaseEntity {

    @Schema(description = "父机构ID")
    private String parentId;

    @Schema(title = "父级标记", description = "0最高级；1租户；2公司")
    private Integer parentCode;

    @Schema(title = "机构编码", description = "自定义")
    private String customCode;

    @NotBlank(message = "机构名称不能为空")
    @Schema(description = "机构/部门名称全称", requiredMode = Schema.RequiredMode.REQUIRED)
    private String name;

    @Schema(description = "简称")
    private String shortName;

    @NotBlank(message = "区域编码不能为空")
    @Schema(title = "区域编码", description = "行政区域编码，和数据权限挂钩", requiredMode = Schema.RequiredMode.REQUIRED)
    private String areaCode;

    @Schema(title = "区域名称", description = "行政区域名称")
    private String areaName;

    @Schema(description = "排序")
    private Integer sort;

    @Schema(description = "经度")
    private Double longitude;

    @Schema(description = "纬度")
    private Double latitude;

    @Schema(description = "详细地址")
    private String address;

    @NotNull(message = "类型不能为空")
    @Schema(title = "类型", description = "1公司；2部门；3岗位", requiredMode = Schema.RequiredMode.REQUIRED)
    private Integer type;

    @Schema(hidden = true)
    @TableField(exist = false, fill = FieldFill.DEFAULT)
    private String organId;

    @TableField(exist = false)
    @Schema(description = "子级")
    private List<Organization> children;
}